//
//  LYYTabBarViewController.m

//  Copyright (c) 2015年 李岩岩. All rights reserved.
//

#import "LYYTabBarViewController.h"
#import "LYYNavigationController.h"
#import "UserPutViewController.h"
#import "PluginViewController.h"
#import "SettingViewController.h"


@interface LYYTabBarViewController ()


@end

@implementation LYYTabBarViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    //获取会话列表
     [self setupAllChildViewControllers];
   
   

}

/*
 *初始化所有的自控制器
 */

- (void)setupAllChildViewControllers{

  

    UserPutViewController *user = [[UserPutViewController alloc]init];
    
    [self setupChildViewController:user title:@"用户" imageName:@"user_normal" selectedImageName:@"user_press"];
    
    PluginViewController *plugin = [[PluginViewController alloc]init];
    
    [self setupChildViewController:plugin title:@"插件" imageName:@"plugin_normal" selectedImageName:@"plugin_press"];
    
    SettingViewController *setting = [[SettingViewController alloc]init];
    
    [self setupChildViewController:setting title:@"设置" imageName:@"set_normal" selectedImageName:@"set_press"];
    
}

/**
 *初始化一个自控制器
 */

- (void)setupChildViewController:(UIViewController *)childVc title:(NSString *)title imageName:(NSString *)imageName selectedImageName:(NSString *)selectedImageName
{
    
     // 1.设置控制器的属性
    childVc.title = title;
    
    UIColor *titleHighlightedColor = [Tool colorWithHex:0x03aceb alpha:1.0];
    [childVc.tabBarItem setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:
                                                       titleHighlightedColor, NSForegroundColorAttributeName,
                                                       nil] forState:UIControlStateSelected];
     // 设置图标
    childVc.tabBarItem.image = [UIImage imageNamed:imageName];
    
    childVc.tabBarItem.selectedImage = [ [UIImage imageNamed:selectedImageName] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    
    // 2.包装一个导航控制器
    LYYNavigationController *nav = [[LYYNavigationController alloc]initWithRootViewController:childVc];
    
    [self addChildViewController:nav];
}

@end
